#include "LightingCommon.fxh"

cbuffer cbPerCall
{
	int gMode;
};

static const int DEPTH = 0;
static const int NORMAL = 1;
static const int DIFFUSE = 2;
static const int SPEC_INTENS = 3;

struct VS_IN
{
	float3 posL     : POSITION;
};

struct VS_OUT
{
	float4 posD         : SV_POSITION;
	float2 texCoord     : TEXCOORD0;
};

VS_OUT VS(VS_IN vIn)
{
	VS_OUT vOut;

	float4 posH = float4(vIn.posL, 1.f);
	vOut.posD = posH;
	vOut.texCoord = posH.xy * float2(0.5f, -0.5f) + float2(0.5f, 0.5f);
	
	return vOut;
}

float4 PS(VS_OUT pIn) : SV_Target
{
	float4 output = float4(0.f, 0.f, 0.f, 1.f);
	if(gMode == DEPTH)
	{
		float depth = getDepthFromGBuffer(pIn.texCoord);
		if(depth > 0.0f)
			 depth = 1 - depth / 3000;
		output.rgb = depth.rrr;
	}
	else if(gMode == NORMAL)
	{
		float3 normal = float3(getNormalFromGBuffer(pIn.texCoord));
		output.rgb = normal;
	}
	else if(gMode == DIFFUSE)
	{
		float3 diffuse = float3(0,0,0);//gDiffuse_SpecI_Tex.Sample(gPointSam, pIn.texCoord).rgb;
		output.rgb = diffuse;
	}
	return output;
}

technique11 tech
{
	pass P0
	{
		SetVertexShader( CompileShader( vs_5_0, VS() ) );
		SetGeometryShader( NULL );
		SetPixelShader( CompileShader( ps_5_0, PS() ) );
		
		SetDepthStencilState(DepthOn, 0);
		SetBlendState( NoBlend, float4( 0.f, 0.f, 0.f, 0.f ), 0xFFFFFFFF );
		SetRasterizerState(CullBack);
	}
}
